package com.tencent.wxcloudrun.vo.response.store;

import com.tencent.wxcloudrun.domain.TStoreProd;
import com.tencent.wxcloudrun.dto.StoreProdListResDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author ZhaoZiYin
 * @Date 2025/4/22
 * @Description 查询商品列表请求出参
 */
@Data
@ApiModel(value = "StoreProdListResVo", description = "查询商品列表请求出参")
public class StoreProdListResVo {

    @ApiModelProperty("商品列表")
    private List<StoreProdListResDTO> prodList;

    public void build(List<TStoreProd> prodList) {
        if (!CollectionUtils.isEmpty(prodList)) {
            List<StoreProdListResDTO> prodDTOList = new ArrayList<>(prodList.size());
            for (TStoreProd storeProd : prodList) {
                StoreProdListResDTO resDTO = new StoreProdListResDTO();
                resDTO.setProdTypeId(storeProd.getProdTypeId());
                resDTO.setProdId(storeProd.getId());
                resDTO.setName(storeProd.getName());
                resDTO.setStatus(storeProd.getStatus());
                resDTO.setPrice(storeProd.getPrice());
                resDTO.setImgUrlList(storeProd.getImgUrlList());
                resDTO.setTotalStock(storeProd.getTotalStock());
                prodDTOList.add(resDTO);
            }
            this.setProdList(prodDTOList);
        }
    }

}
